package com.sh.data.engine.application.model.mapper.integration;

import com.sh.data.engine.application.model.request.integration.*;
import com.sh.data.engine.domain.integration.datasource.model.param.*;
import org.mapstruct.Mapper;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/13 13:53
 */
@Mapper(componentModel = "spring")
public interface DataSourceConnectParamMapper {

    DataSourceConnectParam requestToParam(DataSourceConnectionRequest request);

    DataSourceHiveConnectParam requestToParam(DataSourceHiveConnectionRequest request);

    DataSourceMongoConnectParam requestToParam(DataSourceMongoConnectionRequest request);

    DataSourceHDFSConnectParam requestToParam(DataSourceHDFSConnectionRequest request);

    DataSourceIoTDBConnectParam requestToParam(DataSourceIoTDBConnectionRequest request);

    DataSourceInfluxDBConnectParam requestToParam(DataSourceInfluxDBConnectionRequest request);

    default DataSourceConnectParam map(DataSourceConnectionRequest request) {
        if (request == null) {
            return requestToParam(request);
        }

        if (request instanceof DataSourceHDFSConnectionRequest) {
            return requestToParam((DataSourceHDFSConnectionRequest) request);
        } else if (request instanceof DataSourceHiveConnectionRequest) {
            return requestToParam((DataSourceHiveConnectionRequest) request);
        } else if (request instanceof DataSourceIoTDBConnectionRequest) {
            return requestToParam((DataSourceIoTDBConnectionRequest) request);
        } else if (request instanceof DataSourceInfluxDBConnectionRequest) {
            return requestToParam((DataSourceInfluxDBConnectionRequest) request);
        } else if (request instanceof DataSourceMongoConnectionRequest) {
            return requestToParam((DataSourceMongoConnectionRequest) request);
        } else {
            return requestToParam(request);
        }
    }
}
